package com.clock.controller.stage;

import com.clock.common.domain.R;
import com.clock.domain.dto.PostLikeDTO;
import com.clock.domain.dto.PostsLikeDTO;
import com.clock.service.ContentUserLikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(tags = {"点赞"})
@RestController
@RequestMapping("/like")
public class ContentUserLikeController {

    @Resource
    ContentUserLikeService contentUserLikeService;

    @PostMapping("/action")
    @ApiOperation(value = "点赞/取消点赞", notes = "对帖子的点赞或取赞操作")
    public R updatePostLikeState(@RequestBody PostLikeDTO postLikeDTO) throws Exception {
        return contentUserLikeService.updateDiscussPostLikeState(postLikeDTO);
    }

    @PostMapping("/count")
    @ApiOperation(value = "获取点赞数以及判断是否已点赞")
    public R queryPostLikeCountAndIsLiked(@RequestBody PostsLikeDTO postsLikeDTO) throws Exception {

        return contentUserLikeService.queryDiscussPostLikeCountAndIsLike(postsLikeDTO);
    }
}
